# main.py
import uvicorn
from fastapi import FastAPI
from APIS.data_generator_api import router as data_generator_router


def create_app():
    # 创建FastAPI应用实例
    app = FastAPI(
        title="Orange Moon Services API",
        description="统一的API服务入口，包含数据生成等服务",
        version="1.0.0"
    )

    # 注册路由
    register_routes(app)

    # 根路径欢迎信息
    @app.get("/")
    async def root():
        return {
            "message": "Welcome to Orange Moon Services API",
            "version": "1.0.0",
            "docs": "/docs",
            "redoc": "/redoc"
        }

    return app


def register_routes(app: FastAPI):
    """
    统一注册所有路由
    """
    # 注册数据生成器API
    app.include_router(data_generator_router)

    # 在这里可以继续注册其他服务的路由
    # 例如:
    # app.include_router(user_router, prefix="/api/users")
    # app.include_router(auth_router, prefix="/api/auth")


if __name__ == "__main__":
    app = create_app()
    uvicorn.run(
        app,
        host="0.0.0.0",
        port=8000,
        log_level="info"
    )
